<?xml version="1.0"?>
<ScatterFile xmlns="http://schemas.microsoft.com/netmf/ScatterfileSchema.xsd">

    <!-- ATMEL AT91SAM, NO SRAM, SDRAM 64M -->
  <!-- 32MB FLASH Emulation (0x20000000), 31MB SDRAM (0x22000000) -->
  <!-- Last MB (0x23F0 0000) reserved for framebuffer -->


  <Set Name="Valid" Value="false"/>

    <!-- ATMEL SAM9261EK - 64M SDRAM - 160K SRAM - No FLASH -->
    <Set Name="Heap_Begin"      Value="0x23000000"/>
    <Set Name="Heap_End"        Value="0x23EFFFFC"/>
    <Set Name="Stack_Bottom"    Value="0x00326000"/>
    <Set Name="Stack_Top"       Value="0x00327FFC"/>

  <IfDefined Name="PROFILE_BUILD">
    <Set Name="ProfileBuffer_Begin" Value="0x23000000"/>
    <Set Name="ProfileBuffer_End"   Value="0x2300FFFC"/>
    <Set Name="Heap_Begin"          Value="0x23010000"/>
  </IfDefined>

  <If Name="TARGETLOCATION" In="FLASH">


    <!-- the TINYCLR and Hal Code should lie in one partition and the other data/LOG/DEPLOYMENT session should sit in another partition, -->
    <!-- in order to optimized for flash operations while erasing flash that it is still able to implement code from other flash partition -->
    <Set Name="Code_BaseAddress"    Value="0x20000000"/>

<!-- Config_BaseAddress it the NAND address -->
        <Set Name="Config_BaseAddress"   Value="0x00040000"/>    
<!-- ERConfig_BaseAddress is in RW -->
        <Set Name="ERConfig_BaseAddress" Value="0x00020000"/>    
        <Set Name="Config_Size"          Value="0x00020000"/>
    
    <Set Name="Data_BaseAddress"    Value="0x200A0000"/>
    <Set Name="Deploy_BaseAddress"  Value="0x20200000"/>
    <Set Name="Valid"               Value="true"/>
    <Set Name="Code_Size"           Value="%Data_BaseAddress   - Code_BaseAddress%"/>
    <Set Name="Data_Size"           Value="%Deploy_BaseAddress - Data_BaseAddress%"/>
  </If>

  <If Name="TARGETLOCATION" In="RAM">
    <Set Name="ProfileBuffer_Begin" Value="0x22000000"/>
    <Set Name="ProfileBuffer_End"   Value="0x2200FFFC"/>
    <Set Name="Code_BaseAddress" Value="0x22010000"/>
    <Set Name="Code_Size"        Value="0x00FF0000"/>
    <!-- RAM with FLASH config is not needed -->
    <Set Name="Valid"            Value="true"/>
  </If>


    <LoadRegion Name="LR_%TARGETLOCATION%" Base="%Code_BaseAddress%" Options="ABSOLUTE" Size="%Code_Size%">

      <ExecRegion Name="ER_%TARGETLOCATION%" Base="%Code_BaseAddress%" Options="FIXED" Size="">

            <FileMapping Name="FirstEntry.obj"    Options="(+RO, +FIRST)" /> <!-- the entry pointer section goes into this region -->

            <FileMapping Name="*" Options="(SectionForBootstrapOperations)" />

            <FileMapping Name="*" Options="(+RO-CODE)" />

            <FileMapping Name="*" Options="(+RO-DATA)" />
        </ExecRegion>

        <!-- skip vector area -->

        <ExecRegion Name="ER_RAM_RO" Base="0x00000000" Options="ABSOLUTE" Size="0x1A000">

            <!-- the following are dotNetMF's HAL library -->

            <FileMapping Name="VectorsTrampolines.obj" Options="(+RO, +FIRST)" /> <!-- for vector handlers to be far from the vectors -->

            <FileMapping Name="*" Options="(SectionForFlashOperations)" />

            <FileMapping Name="*" Options="(SectionForBootstrapInRam)" />

        </ExecRegion>


        <ExecRegion Name="ER_RAM_RW" Base="+0" Options="ABSOLUTE" Size="0xC000">

            <FileMapping Name="*" Options="(+RW-DATA, +ZI)" />

        </ExecRegion>

        <ExecRegion Name="ER_HEAP_BEGIN" Base="%Heap_Begin%" Options="ABSOLUTE" Size="UNINIT">
            <FileMapping Name="*" Options="(SectionForHeapBegin)" />
        </ExecRegion>

        <!-- everything between heapbegin and heapend will be allocated for a heap -->

        <ExecRegion Name="ER_HEAP_END" Base="%Heap_End%" Options="ABSOLUTE" Size="UNINIT">
            <FileMapping Name="*" Options="(SectionForHeapEnd)" />
        </ExecRegion>


        <!-- this must go last here to provide a low water mark on the stack -->

        <ExecRegion Name="ER_STACK_BOTTOM" Base="%Stack_Bottom%" Options="ABSOLUTE" Size="UNINIT">
            <FileMapping Name="*" Options="(SectionForStackBottom)" />
        </ExecRegion>
        
        <ExecRegion Name="ER_STACK_TOP" Base="%Stack_Top%" Options="ABSOLUTE" Size="UNINIT">
            <FileMapping Name="*" Options="(SectionForStackTop)" />
        </ExecRegion>

    </LoadRegion>

    <IfDefined Name="Config_BaseAddress">

        <LoadRegion Name="LR_CONFIG" Base="%Config_BaseAddress%" Options="ABSOLUTE" Size="%Config_Size%">

            <ExecRegion Name="ER_CONFIG" Base="%ERConfig_BaseAddress%" Options="ABSOLUTE" Size="%Config_Size%">

                <FileMapping Name="*" Options="(SectionForConfig)" />

            </ExecRegion>

        </LoadRegion>

    </IfDefined>


</ScatterFile>
